package de.connecttext.dao.solr;

import java.io.IOException;
import java.util.Iterator;

import de.connecttext.model.TextDocument;

/**
 * Iterator to iterate over all Textdocuments provided by the SolrDao Interface.
 * @author conrad
 *
 */
public class SolrDocumentIterator implements Iterator<TextDocument> {

	/**
	 * Count of the Documents in SolrDao
	 */
	private int docsInIndex = 0;
	/**
	 * pointer to the Document that is returned next
	 */
	private int currentDoc = 0;
	/**
	 * pointer to the calling Dao
	 */
	private SolrDao solrDao;
	public SolrDocumentIterator(SolrDao solrDao) throws IOException {
		super();
		this.solrDao = solrDao;
		this.docsInIndex = solrDao.length();
	}
	@Override
	public boolean hasNext() {
		if (currentDoc < docsInIndex) return true;
		return false;
	}

	@Override
	public TextDocument next() {
		return solrDao.get(currentDoc++);		
	}
	@Override
	public void remove() {
		//Not available yet, not planned either
	}


}
